Stream Ops StreamStorageRootFS
Jakob Jenkov |
The Stream Ops for Java class named StreamStorageRootFS
(com.nanosai.streamops.engine.storage.file.StreamStorageRootFS) class represents
the root of a file based stream storage system. When you create a StreamStorageRootFS instance
you tell it what directory is the root of the stream storage in the file system. Whenever you create a new
stream via this StreamStorageRootFS object, that stream's data will be stored in a stream
specific directory nested inside the root directory given to the StreamStorageRootFS at creation.
Create a StreamStorageRootFS Instance
In order to use a StreamStorageRootFS you must first create a StreamStorageRootFS
instance. Here is an example of creating a StreamStorageRootFS :
StreamStorageRootFS streamStorageRootFS = new StreamStorageRootFS("/streams");
Get Root Directory Path
You can always obtain the root directory path a StreamStorageRootFS was created with
via its getRootDirPath() method. Here is an example of obtaining the root directory path
of a StreamStorageRootFS via its getRootDirPath() method:
String rootDirPath = streamStorageRootFS.getRootDirPath()
Create a StreamStorageFS Instance
Once you have created a StreamStorageRootFS instance, you can create one or more
StreamStorageFS instances from it. A StreamStorageFS object represents a
file based storage system for a single data stream. Here is an example of creating a StreamStorageFS
object via a StreamStorageRootFS object:
StreamStorageRootFS streamStorageRootFS = new StreamStorageRootFS("/streams");
StreamStorageFS streamStorageFS =
streamStorageRootFS.createStreamStorage("stream-1");
This example creates a single FileStreamStorage instance which represents a data stream named
stream-1.
Set Stream Storage File Block Length
When you write records to a stream via the StreamStorageFS instance, the StreamStorageFS
class will divide the records into multiple files. Each file will be have a maximal length which you can set
when you create a StreamStorageFS instance. For instance, if you set the file block max length to
64MB, then all the files the stream data will be divided into will never be larger than 64MB. Records are never
split between files. Each file block will contain full records only.
Here is an example of creating a StreamStorageFS instance with a file block max length of 2MB:
StreamStorageRootFS streamStorageRootFS = new StreamStorageRootFS("/streams");
StreamStorageFS streamStorageFS =
streamStorageRootFS.createStreamStorage("stream-1", 2 * 1024 * 1024);
| Tweet | |
Jakob Jenkov | |









